# Maintainer: Christian Hesse <mail@eworm.de>
# Contributor: mathieu.clabaut <mathieu.clabaut@gmail.com>
# Contributor: Buce <dmbuce@gmail.com>
# Contributor: Danie Roux <accounts@danieroux.com>

pkgname=etckeeper
_tag='5db19626c0a14675e1a6c6745981643ab4292669' # git rev-parse ${pkgver}
pkgver=1.18.20
pkgrel=2
pkgdesc='Collection of tools to let /etc be stored in a git, hg or bzr repository'
arch=('any')
url='https://etckeeper.branchable.com/'
license=('GPL2')
depends=('git' 'diffutils' 'sed')
makedepends=('git' 'mercurial' 'breezy')
optdepends=('mercurial: use mercurial for version control'
            'breezy: use bazaar for version control')
backup=('etc/etckeeper/etckeeper.conf')
source=("git+https://git.kitenet.net/git/etckeeper.git#tag=${_tag}?signed"
        '0001-breezy.patch')
sha256sums=('SKIP'
            'fbfce54167828db00a2dcec02cf75c5df32302fae5411fd68dfb1a521675be6c')
validpgpkeys=('E85A5F63B31D24C1EBF0D81CC910D9222512E3C7') # Joey Hess <joeyh@joeyh.name>

prepare() {
	cd ${pkgname}

	patch -Np1 < ../0001-breezy.patch
}

build() {
	cd ${pkgname}

	# We want pacman :D
	sed -i -e "/^LOWLEVEL_PACKAGE_MANAGER/c LOWLEVEL_PACKAGE_MANAGER=pacman" \
		-e "/^HIGHLEVEL_PACKAGE_MANAGER/c HIGHLEVEL_PACKAGE_MANAGER=pacman" etckeeper.conf

	# zsh completion directory
	sed -i '/^zshcompletiondir=/c zshcompletiondir=${prefix}/share/zsh/site-functions' Makefile
}

package() {
	cd ${pkgname}
	make DESTDIR="${pkgdir}" systemddir=/usr/lib/systemd/system install
}
